package com.asdf.tests;

import static org.junit.Assert.assertEquals;

import java.util.List;

import org.junit.Test;

import com.asdf.application.NetServiceSimulator;
import com.asdf.db.DataBase;
import com.asdf.db.DataBase.DataSource;
import com.asdf.db.operations.airport.LocateAirport;
import com.asdf.db.results.airport.AirportResult;
import com.asdf.entities.Airport;

public class DBAirportLocate extends AirportTest
{
	@SuppressWarnings({ "unchecked" })
	@Test
	public void airportLocate()
	{
		NetServiceSimulator simulator = new NetServiceSimulator( );
		List<Airport> list = null;
		
		simulator.loadAirports( "airports.xml");
		list = (List<Airport>)DataBase.getInstance( ).getDataSource( DataSource.AirportList);
		
		for (int i = 0; i < arr.length; ++i)
		{
			LocateAirport op = new LocateAirport(list);
			AirportResult res = null;
			Airport airport = null;
			
			op.setAirportID(arr[i][0]);
			res = (AirportResult)DataBase.getInstance().Do(op);
			airport = res.getResultSet().get(0);
			
			assertEquals("airportLocate[" + i + "][result-list-length]", 1, res.getResultSet().size());
			assertEquals("airportLocate[" + i + "][id]", arr[i][0], airport.getId());
			assertEquals("airportLocate[" + i + "][name]", arr[i][1], airport.getName());
			assertEquals("airportLocate[" + i + "][country]", arr[i][2], airport.getCountry());
			assertEquals("airportLocate[" + i + "][rate]", Double.parseDouble(arr[i][3]), airport.getRate());
			assertEquals("airportLocate[" + i + "][license]", arr[i][4], airport.getLicenseFile());
		}
	}
}
